package com.itqf.yun.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itqf.yun.dto.BillDto;
import com.itqf.yun.mapper.BillMapper;
import com.itqf.yun.pojo.Bill;
import com.itqf.yun.service.BillService;
import com.itqf.yun.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * projectName: last
 *
 * @author: Ayangcx
 * time: 2021/9/28 22:27
 * description:
 */
@Service
public class BillServiceImpl implements BillService {
	@Autowired
	private BillMapper billMapper;

	@Override
	public Object billSearch (Integer bstate) {
		List<Bill> querybill = billMapper.querybill(bstate);
		return querybill;
	}

	@Override
	public Object blist (BillDto billDto) {
		List<Bill> querybill = billMapper.querybills(billDto);
		return querybill;
	}

	@Override
	public Object delete (int bid) {
		Bill bill = new Bill();
		bill.setBid(bid);
		bill.setBdeleted(1);
		int row = billMapper.updateById(bill);
		return R.FAIL("删除数据成功");
	}

	@Override
	public Object update (Bill bill) {
		bill.setBstate(1);
		int rows = 0;
		try {
			rows = billMapper.updateById(bill);
		} catch (Exception e) {

		}
		if (rows == 0) {
			return R.FAIL("状态超出，修改失败！");
		}
		return R.OK("订单状态修改成功！");
	}
}
